<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        // ES5写法
        //构造函数
        function Person(name, age) {
            this.name = name
            this.age = age
        }
        //原型对象
        Person.prototype.eat = function () {
            console.log('我要吃饭了');
        }
        //实例对象
        let p1 = new Person('曾鹏', 20)
        console.log(p1);

        // ES6类函数
        class Person1 {
            //构造函数
            constructor(name, age) {
                this.name = name
                this.age = age
            }
            //原型对象
            eat() {
                console.log('我要吃饭了');
            }
        }
        //调用类函数
        let p2 = new Person1('ikun', 32)
        console.log(p2);
    </script>
</body>

</html>